package com.xiaoquan.graphql.resolver;


import com.coxautodev.graphql.tools.GraphQLQueryResolver;
import com.xiaoquan.graphql.entity.Author;
import com.xiaoquan.graphql.entity.Book;

import java.util.Arrays;
import java.util.List;

/**
 * Created by genghz on 18/3/28.
 */
public class Query implements GraphQLQueryResolver {

    public Author findOneAuthor(Long id) {
        Author author = new Author();
        author.setId(id);
        author.setLastName("LastName-" + id);
        author.setFirstName("FirstName-" + id);
        return author;
    }

    public List<Author> findAllAuthors() {
        Author author = new Author();
        Long id = 99L;
        author.setId(id);
        author.setLastName("LastName-" + id);
        author.setFirstName("FirstName-" + id);
        return Arrays.asList(author);
    }

    public Long countAuthors() {
        return 99L;
    }

    public List<Book> findAllBooks() {
        Book book = new Book();
        book.setAuthorId(1111L);
        book.setIsbn("No");
        book.setPageCount(99);
        book.setTitle("test");
        return Arrays.asList(book);
    }

    public Long countBooks() {
        return 9999L;
    }
}
